<template>
  <div>
    <div class="page">
      <header>
        <!-- 设置 -->
        <div class="city flex jc-sb bg-fff">
          <router-link to="/my">
            <span class="icon iconfont iconleft ml-10 f24 orange"></span>
          </router-link>
          <p class="f16">设置</p>
          <span style="visibility:hidden;" class="icon iconfont ml-10">&#xe64b;</span>
        </div>
      </header>

      <div class="bg-fff">
        <div class="flex jc-sb aic bd-gray id ml-10 mt-10 bg-fff">
          <p class="f18">消息推送</p>

          <van-switch active-color="orange" v-model="checked" class="mr-15"/>
        </div>
        <div class="bd-gray id ml-10 bg-fff">
          <p class="f18">检查更新</p>
        </div>
      </div>

      <!-- 退出登录 -->
      <div class="id f16 flex fcc bg-fff fixed w100pc mt-10" @click="logout">
        <p class="orange">退出登录</p>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      checked: true
    };
  },

  methods: {
    // 退出登录
    async logout() {
      let url = "/user/logout";
      try {
        let res = await this.$axios.get(url);
        this.$store.commit("updateLogin", false);
        this.$store.commit("updateToken", "");
        this.$store.commit("updateUsername", "");
        this.$router.push("/my");
        this.$toast.success("退出成功");
      } catch (error) {}
    }
  }
};
</script>

<style lang="less" scoped>
@import "../../style/set.less";
</style>

